package com.zahb.qadx.ui.adapter;


import android.media.Image;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.zahb.qadx.R;
import com.zahb.qadx.model.AssessmentBean;
import com.zahb.qadx.model.CommentContentBean;
import com.zahb.qadx.ui.view.RatingBarView;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;


public class CommentTeacherAdapter extends BaseQuickAdapter<CommentContentBean, BaseViewHolder> {
    public boolean mClickable =true;
    public CommentTeacherAdapter(int layoutResId, @Nullable List<CommentContentBean> data) {
        super(layoutResId, data);
    }
    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, CommentContentBean s) {

        TextView tvDes = baseViewHolder.getView(R.id.tvDes);

        baseViewHolder.setText(R.id.tvTitle,s.content);

        RatingBarView bar = baseViewHolder.getView(R.id.bar);
        bar.setClickable(mClickable);
        bar.setOnRatingListener(new RatingBarView.OnRatingListener() {
            @Override
            public void onRating(Object bindObject, int RatingScore) {
                s.level = RatingScore;

                setDes(s.level,tvDes);
            }
        });

        if(s.level!=0){
            bar.setStar(s.level,false);
        }
        setDes(s.level,tvDes);

    }

    public void setDes(int score, TextView tv){
        if(score==0){
            tv.setText("");
        }
        if(score==1){
            tv.setText("非常不满意");
        }
        if(score==2){
            tv.setText("不满意");
        }
        if(score==3){
            tv.setText("一般般");
        }
        if(score==4){
            tv.setText("比较满意");
        }
        if(score==5){
            tv.setText("非常满意");
        }
    }
}
